package com.deyuanyun.pic.ctrl.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.common.util.ajax.AjaxSupport;
import com.deyuanyun.pic.pipe.controller.BaseController;
import com.deyuanyun.pic.wf.domain.Node;
import com.deyuanyun.pic.wf.domain.ProcessDefinition;
import com.deyuanyun.pic.wf.domain.ProcessInstance;
import com.deyuanyun.pic.wf.service.ProcessDefinitionService;
import com.deyuanyun.pic.wf.service.RepairWorkflowService;

/**
 *  维修工作流程Controller
 *
 * @author ChenKui
 * @date 2016-06-16
 */
@Controller
@RequestMapping("/corrctrl/RepairWorkflow")
public class CoatRepairWorkflowController extends BaseController{


    private @Autowired RepairWorkflowService repairWorkflowService;
    private @Autowired ProcessDefinitionService processDefinitionService;


    //初始化进入页面
    @RequestMapping("/init.html")
    public ModelAndView init1(ModelMap model) {
        
        return forword("/corrctrl/repair/flowList", model);
    }
    
    //页面初始化数据
    @RequestMapping("/init.json")
    @ResponseBody
    public void init2(ModelMap model) {

        List<Node> node_list = repairWorkflowService.queryNodeByNeed();
        List<ProcessDefinition> pd_list = processDefinitionService.queryProcessDefinitionCoat();
        List<Map<String,Object>> pi_list = repairWorkflowService.queryProcessInstanceList();
        
        model.addAttribute("node_list", node_list);
        model.addAttribute("pd_list", pd_list);
        model.addAttribute("pi_list", pi_list);
        
        AjaxSupport.sendSuccessText("success", model);
    }


}
